<template>
  <div class="tsb-use-decs" :class="{ popover: popover }">
    <div class="title">
      <span>{{ tsbDecsTitle }}</span>
    </div>
    <ul class="list" v-if="tsbDecsList">
      <li v-for="(it, i) in tsbDecsList" :key="i">
        <div class="r-title">{{ it.title }}</div>
        <div class="r-msg">{{ it.msg }}</div>
      </li>
    </ul>
  </div>
</template>
<script setup lang="ts">
import { requestConfig } from "@/utils/costum-config";
import { defineProps, ref, computed, onMounted } from "vue";
const props = defineProps({
  popover: {
    type: Boolean,
    default: false
  }
});
const popover = computed(() => props.popover);
const tsbDecsTitle = ref("");
const tsbDecsList = ref<any[]>([]);
function getTsbDecs() {
  if (tsbDecsList.value.length) {
    tsbDecsTitle.value = "";
    tsbDecsList.value = [];
  }
  requestConfig("fybsysm", { isCache: true }).then((res: any) => {
    const { list, title } = res.params || {};
    tsbDecsTitle.value = title || "";
    if (Array.isArray(list)) {
      tsbDecsList.value = list;
    }
  });
}
onMounted(() => {
  getTsbDecs();
});
</script>
<style lang="scss" scoped>
.popover.tsb-use-decs {
  font-size: 12px;
  color: #fff;
  max-height: 310px;
  overflow: auto;
  .title {
    font-weight: bold;
    text-align: center;
  }
  .list {
    line-height: 16px;
    margin-top: 5px;
    li {
      margin-top: 5px;
    }
    .r-msg {
      opacity: 0.7;
      text-indent: 2em;
      margin-top: 2px;
      padding: 0 10px;
    }
  }
}
</style>
